//
//  RankCell.m
//  Coco_Music
//
//  Created by dlios on 15-6-20.
//  Copyright (c) 2015年 寇广超. All rights reserved.
//

#import "RankCell.h"

@implementation RankCell
-(void)dealloc
{
    [_myImageView release];
    [_KindLabel release];
    [_SongLabel1 release];
    [_SongLabel2 release];
    [_SongLabel3 release];
    [_rank release];
    [_ImageLine release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
    
}
-(void)createSubViews
{
    self.myImageView =[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, [UIScreen mainScreen].bounds.size.width/3, [UIScreen mainScreen].bounds.size.width/3)];
    self.myImageView.backgroundColor=[UIColor blackColor];
    self.myImageView.layer.masksToBounds = YES;
    self.myImageView.layer.cornerRadius =10;
    
    
    [self addSubview:self.myImageView];
    [_myImageView release];
    
    
    self.ImageLine = [[UIImageView alloc]initWithFrame:CGRectMake(_myImageView.frame.size.width+5 ,self.myImageView.frame.size.height+self.myImageView.frame.origin.y+5, [UIScreen mainScreen].bounds.size.width-40, 1)];
    _ImageLine.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_ImageLine];
    [self.ImageLine release];


    self.KindLabel =[[UILabel alloc]initWithFrame:CGRectMake(self.myImageView.frame.origin.x+self.myImageView.frame.size.width +20, self.myImageView.frame.origin.y,[UIScreen mainScreen].bounds.size.width/2, 30)];
    self.KindLabel.shadowColor = [UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0.7];
    self.KindLabel.numberOfLines = 0;
    self.KindLabel.font =[UIFont systemFontOfSize:16];
    [self addSubview:self.KindLabel];
    [_KindLabel release];
    

    

    self.SongLabel1 =[[UILabel alloc]initWithFrame:CGRectMake(self.KindLabel.frame.origin.x,self.KindLabel.frame.origin.y+self.KindLabel.frame.size.height,[UIScreen mainScreen].bounds.size.width/2 , 30)];
    self.SongLabel1.textColor =[UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0.9];
    self.SongLabel1.numberOfLines = 0;
    self.SongLabel1.font =[UIFont systemFontOfSize:13];
    [self addSubview:self.SongLabel1];
    [_SongLabel1 release];
    

 
   
    self.SongLabel2 =[[UILabel alloc]initWithFrame:CGRectMake(self.KindLabel.frame.origin.x, self.SongLabel1.frame.origin.y+self.SongLabel1.frame.size.height, [UIScreen mainScreen].bounds.size.width/2, 30)];
    self.SongLabel2.textColor =[UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0.9];

    self.SongLabel2.numberOfLines = 0;
    [self addSubview:self.SongLabel2];
    self.SongLabel2.font =[UIFont systemFontOfSize:13];
    [_SongLabel2 release];

     self.SongLabel3 =[[UILabel alloc]initWithFrame:CGRectMake(self.KindLabel.frame.origin.x, self.SongLabel2.frame.origin.y+30, [UIScreen mainScreen].bounds.size.width/2, 30)];
    self.SongLabel3.textColor = [UIColor colorWithRed:0.3 green:0.4 blue:0.5 alpha:0.9];
    [self addSubview:self.SongLabel3];
    self.SongLabel3.numberOfLines = 0;
    self.SongLabel3.font =[UIFont systemFontOfSize:13];
    [_SongLabel3 release];
    
    
}
-(void)setRank:(Rank *)rank
{
    if (_rank != rank) {
        [_rank release];
        _rank =[rank retain];
    }
    NSMutableArray *singerArray =[NSMutableArray array];
    
    NSMutableArray *songNameArray=[NSMutableArray array];

    self.KindLabel.text = [NSString stringWithFormat:@"%@",rank.title];
    for (NSMutableDictionary *dic in rank.songlist) {
      NSString *singerName  =[dic objectForKey:@"singerName"];
       NSString *songName =[dic objectForKey:@"songName"];
        [singerArray addObject:singerName];
        [songNameArray addObject:songName];
}
   
self.SongLabel1.text =[NSString stringWithFormat:@" 1 %@ --%@",[singerArray objectAtIndex:0],[songNameArray objectAtIndex:0]];

self.SongLabel2.text =[NSString stringWithFormat:@" 2 %@ --%@",[singerArray objectAtIndex:1],[songNameArray objectAtIndex:1]];
self.SongLabel3.text =[NSString stringWithFormat:@" 3 %@ --%@",[singerArray objectAtIndex:2],[songNameArray objectAtIndex:2]];

        NSURL *url =[NSURL URLWithString:rank.pic_url];
        [self.myImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"cm2_default_artist_banner-1"]];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
